package SURF;
import SIFT.SIFT_ExtractPointRoi;
import SIFT.util.Feature;
import ij.IJ;
import java.util.List;

import SURF.util.InterestPoint;
import java.io.File;




// Designed according to the "PlugIn Design Guidelines" 
// http://pacific.mpi-cbg.de/wiki/index.php/PlugIn_Design_Guidelines

public class Save_Interest_Points_To_File {
	String title = "SURF: Save Interest Points To File";

	public void SurfFile(int frame,String Videofile)
        {
            String[] nn = Videofile.split("/");
            Videofile = nn[nn.length-1];

            List<InterestPoint> ipts = IJFacade.getLastResult();
            if (ipts == null) {
                    IJ.error(title, "No cached result.\nRun 'Find Interest Points' first.");
                    return;
            }

            File dir = new File("Descriptors/"+Videofile);
            dir.mkdir();

            String F = String.valueOf(frame);
            if(F.length()==1)
                F="00"+F;

            if(F.length()==2)
                F="0"+F;

            String fullName = "Descriptors/"+Videofile+"/"+Videofile+"_"+F+".surf";
            InterestPoint.SurfSaveToFile(ipts, fullName);
		
	}
        public void SiftFile(int frame,String Videofile)
        {
            String[] nn = Videofile.split("/");
            Videofile = nn[nn.length-1];
            List<Feature> ipts = SIFT_ExtractPointRoi.getLastResult();

            if (ipts == null) {
                    IJ.error(title, "No cached result.\nRun 'Find Interest Points' first.");
                    return;
            }
            File dir = new File("Descriptors/"+Videofile);
            dir.mkdir();

            String F = String.valueOf(frame);
            if(F.length()==1)
                F="00"+F;

            if(F.length()==2)
                F="0"+F;
            String fullName = "Descriptors/"+Videofile+"/"+Videofile+"_"+F+".sift";
            Feature.SiftSaveToFile(ipts, fullName);

	}

}
